<?php
  //global $customer_id;
  require('includes/application_top.php');
  require('includes/classes/http_client.php');

  $breadcrumb->add('Trợ giúp', tep_href_link('helps.php', '', 'SSL')); 
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
    <title><?php echo TITLE; ?></title>
    <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">  
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-22140239-1']);
  _gaq.push(['_setDomainName', '.ushop.vn']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>	
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="3" cellpadding="3">
  <tr>
    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
    </table></td>
<!-- body_text //-->
    <td width="100%" valign="top" align="left">  
    <table border="0" cellpadding="2" cellspacing="2" width="100%">
    <div class="home-newprodbar">
                    <div class="lblTitle">Liên hệ</div>
                </div><br /><br /><br /> 
        
        <?php        
            $store_query = tep_db_query("select * from " . TABLE_CONFIGURATION . " where configuration_id = '1'");
            $store = tep_db_fetch_array($store_query);                
        ?>
        <tr><td class="field contacttitle" colspan="2"><?php echo $store['configuration_value']; ?></td></tr>
        <!--<tr>
        <?php        
            $store_owner_query = tep_db_query("select * from " . TABLE_CONFIGURATION . " where configuration_id = '2'");
            $store_owner = tep_db_fetch_array($store_owner_query);                
        ?>
            <td class="field">Tên liên hệ:</td>
            <td><?php echo $store_owner['configuration_value']; ?></td>
        </tr>
        <tr>
        <?php        
            $store_address_query = tep_db_query("select * from " . TABLE_CONFIGURATION . " where configuration_id = '161'");
            $store_address = tep_db_fetch_array($store_address_query);                
        ?>
            <td class="field">Địa chỉ:</td>
            <td><?php echo $store_address['configuration_value']; ?></td>
        </tr>-->        
        <tr  style="height: 43px;">
        <?php        
            $store_phone_query = tep_db_query("select * from " . TABLE_CONFIGURATION . " where configuration_id = '162'");
            $store_phone = tep_db_fetch_array($store_phone_query);                
        ?>
            <td class="field bold_text" width="100px">Điện thoại:</td>
            <td class="form_text"><?php echo $store_phone['configuration_value']; ?></td>
        </tr>
        <tr  style="height: 43px;">
        <?php        
            $store_phone_query = tep_db_query("select * from " . TABLE_CONFIGURATION . " where configuration_id = '166'");
            $store_hotphone = tep_db_fetch_array($store_phone_query);                
        ?>
            <td class="field bold_text" width="100px">Hotline:</td>
            <td class="form_text"><?php echo $store_hotphone['configuration_value']; ?></td>
        </tr>
        <tr><td class="field supportonline" colspan="2">Hỗ trợ trực tuyến</td></tr>
        <tr  style="height: 43px;">
        <?php        
            $store_email_query = tep_db_query("select * from " . TABLE_CONFIGURATION . " where configuration_id = '3'");
            $store_email = tep_db_fetch_array($store_email_query);                
        ?>
            <td class="field bold_text">E-mail:</td>
            <td class="contactemail"><?php echo $store_email['configuration_value']; ?></td>
        </tr>
        
        <!--<script type="text/javascript" src="templates/phuocndt/js/jquery-1.4.2.js"></script>
        <script type="text/javascript" src="templates/phuocndt/js/jquery.validate.js"></script>
        <script language="javascript">
        jQuery(document).ready(function($){
            
        });
        </script>-->
        <?php
            session_start();
            // Get value form
            $c_name = $_POST['c_name'];
            $c_email = $_POST['c_email'];
            $c_phone = $_POST['c_phone'];
            $c_yahoo = $_POST['c_yahoo'];
            $c_title = $_POST['c_title'];
            $c_des = $_POST['c_des'];
            // Session for value
            $_SESSION['c_name'] = $c_name;
            $_SESSION['c_email']= $c_email;
            $_SESSION['c_phone']= $c_phone;
            $_SESSION['c_yahoo']= $c_yahoo;
            $_SESSION['c_title']= $c_title;
            $_SESSION['c_des']  = $c_des;
            //
            date_default_timezone_set('Asia/Saigon');
            $created = date("Y-m-d H:i:s");            
            
            $captcha = $_POST['captcha'];
            //echo $_SESSION['string_captcha'];
            //print_r($_SESSION);
            if($captcha){
                if($captcha == $_SESSION['string_captcha']){
                    tep_db_query("insert into contacts (c_name,c_email,c_phone,c_yahoo,c_title,c_des,created) values ('".$c_name."','".$c_email."','".$c_phone."','".$c_yahoo."','".$c_title."','".$c_des."','".$created."')");
                    
                    $message = 'Liên hệ từ '.$c_name.',<br />';
                    $message .= 'Email: '.$c_email.'<br />';
                    $message .= 'Điện thoại: '.$c_phone.'<br />';
                    $message .= 'Yahoo: '.$c_yahoo.'<br />';
                    $message .= 'Nội dung: '.$c_des.'<br />';
                    
                    require_once('ext/Rmail.php');    
                    $mail = new Rmail();        
                    $mail->setPriority('high');        
                    $mail->setFrom('ushop <ushop@ushop.vn>');
                    $mail->setReceipt('ushop@ushop.vn');
                    $mail->setSubject($c_title);                                        
                    $mail->setHTML($message);                    
                	$address = $store_email['configuration_value'];
                    //$address = 'phuocndt@zing.vn';	
                    $result  = $mail->send(array($address),'smtp');
                    
                    /*include 'ext/class.phpmailer.php';
                    $mail             = new PHPMailer();
                    $mail->IsSMTP(); // telling the class to use SMTP
                    $mail->Host       = "ushop.vn"; // SMTP server
                    $mail->SMTPAuth   = true;                  // enable SMTP authentication
                    $mail->Port       = 25;                    // set the SMTP port
                    $mail->Username   = "ushop"; // SMTP account username
                    $mail->Password   = "letmein@123";        // SMTP account password                    
                    $mail->SetFrom($c_email,$c_name);
                    $mail->AddReplyTo($c_email,$c_name);
                    
                    $mail->Subject    = $c_title;                    
                    $mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
                    $mail->MsgHTML($message);
                    $mail->AddAddress("phuocndt@gmail.com", "phuocndt");
                    $mail->Send();*/
                    
                    /*$to = $store_email['configuration_value'];
                    $subject = 'ushop.vn - '.$c_title;
                    // To send HTML mail, the Content-type header must be set
                    $headers  = 'MIME-Version: 1.0' . "\r\n";
                    $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";                
                    // Additional headers
                    $headers .= 'To: '.$store_email['configuration_value'] . "\r\n";
                    $headers .= 'From: '.$c_name.' <'.$c_email.'>' . "\r\n";                
                    // Mail it
                    mail($to, $subject, $message, $headers);*/
                    
                    echo '<div style="padding-left:30px;">Cảm ơn bạn đã gửi liên hệ cho chúng tôi!</div>';
                    unset($_SESSION['c_name']);
                    unset($_SESSION['c_email']);
                    unset($_SESSION['c_phone']);
                    unset($_SESSION['c_yahoo']);
                    unset($_SESSION['c_title']);
                    unset($_SESSION['c_des']);
                }else{
                    echo '<div style="padding-left:30px;"><font color="red"><b>Hình ảnh xác nhận bạn nhập chưa đúng !</b></font></div>';
                    //echo $captcha .'='.$_SESSION['string_captcha'];    
                }
            }else{
                //echo 'Vui lòng điền mã xác nhận!';
            }             
        ?>
        <!-- Form contacts -->
        <form id="contactform" name="contactform" method="post" action="contacts.php">
        <tr style="height: 43px;">
            <td class="field bold_text" width="154px" >Họ tên (*)</td>
            <td class="form_text"><input id="c_name" name="c_name" style="width: 235px;" value="<?php echo $_SESSION['c_name']; ?>" /></td>
        </tr>
        <tr style="height: 43px;">
            <td class="field bold_text">Địa chỉ email (*)</td>
            <td class="form_text"><input id="c_email" name="c_email" style="width: 235px;" value="<?php echo $_SESSION['c_email']; ?>" /></td>
        </tr>
        <tr style="height: 43px;">
            <td class="field bold_text">Điện thoại (*)</td>
            <td class="form_text"><input id="c_phone" name="c_phone" style="width: 235px;" value="<?php echo $_SESSION['c_phone']; ?>" /></td>
        </tr>
        <tr style="height: 43px;">
            <td class="field bold_text">Nick Yahoo (*)</td>
            <td class="form_text"><input id="c_yahoo" name="c_yahoo" style="width: 235px;" value="<?php echo $_SESSION['c_yahoo']; ?>" /></td>
        </tr>
        <tr style="height: 43px;">
            <td class="field bold_text">Tiêu đề (*)</td>
            <td class="form_text"><input id="c_title" name="c_title" style="width: 235px;" value="<?php echo $_SESSION['c_title']; ?>" /></td>
        </tr>
        <tr style="height: 43px;">
            <td class="field bold_text">Yêu cầu (*)</td>
            <td class="form_text"><textarea id="c_des" name="c_des" cols="32" rows="4"><?php echo $_SESSION['c_des']; ?></textarea></td>
        </tr>
        <tr style="height: 43px;">
            <td class="field bold_text"></td>
            <td class="form_text"><img src="imagebuilder.php" border="1" /></td>
        </tr>
        <tr style="height: 43px;">
            <td class="field bold_text"></td>
            <td class="form_text"><input type="text" name="captcha" style="width: 147px;" /></td>
        </tr>
        <tr>
        <td colspan="2" align="center"><a href="images/map.png" id="example1">Xem bản đồ</a></td>
        </tr>
        <tr style="height: 43px;">
            <td  colspan="2" align="center"><a href="javascript:history.go(-1)"><input class="checkout" type="button" value="Bỏ qua" onclick="javascript:history.go(-1)" /></a><input class="checkout" type="submit" value="Gửi" /></td>
          
        </tr>        
        </form>
        <!-- End form contact -->
    </table>
    
</td>
<!-- body_text_eof //-->
    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->
    </table></td>
  </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
